package com.jn.okhttp.views;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.jn.okhttp.R;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btnHot, btnTranslate, btnDictionary;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 初始化按钮
        btnHot = findViewById(R.id.btn_hot_search);
        btnTranslate = findViewById(R.id.btn_translate);
        btnDictionary = findViewById(R.id.btn_dictionary);

        // 设置点击监听器
        btnHot.setOnClickListener(this);
        btnTranslate.setOnClickListener(this);
        btnDictionary.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.btn_hot_search) {
            Intent intent = new Intent(this, HotSearchActivity.class);
            startActivity(intent);
        } else if (id == R.id.btn_translate) {
            Intent intent = new Intent(this, TranslateActivity.class);
            startActivity(intent);
        } else if (id == R.id.btn_dictionary) {
            Intent intent = new Intent(this, ZidianActivity.class);
            startActivity(intent);
        }
    }
}